<template>
<div>

  {{list}}
  <table>
    <tr>
      <td>
        标题
      </td>
    </tr>
    <tr v-for="i in list" :key="i">
      <td >
      <van-button style="color: aqua" @click="update_bue(i.id)" v-if="i.state==1">{{i.title}}</van-button>
      </td>

      <td>
        <van-button @click="update_bue(i.id)" style="color: blue" v-if="i.state==2">{{i.title}}</van-button>
      </td>
    </tr>
  </table>
  <van-popup v-model:show="show" style="width: 400px;height: 200px">
    查看详情
    <table>
      <tr>
        <td>
          标题
        </td>
        <td>
          内容
        </td>
      </tr>
      <tr>
        <td>
          {{dict.title}}
        </td>
        <td>
<!--          {{dict.canten}}-->
<!--          <v-html></v-html>-->
          <div v-html="dict.canten"></div>
        </td>
      </tr>
    </table>
  </van-popup>
</div>
</template>

<script>
export default {
name: "My_news",
  data(){
  return{
  list:[],
    show:false,
    dict:[]
  }
  },
  mounted() {
  this.get_data()
  },
  methods:{
    update_bue(id){
      this.show=true
      console.log(id)
      this.myaxios('http://localhost:5000/send_message','put',{'userid':localStorage.getItem('userid'),'message_id':id})
      .then(res=>{
        console.log(res)
      })
      this.myaxios('http://localhost:5000/get_message','get',{'id':id})
      .then(res=>{
        console.log(res)
        this.dict=res.data.dict
      })
    },
  get_data(){
    this.myaxios('http://localhost:5000/send_message','get',{'id':localStorage.getItem('userid')})
    .then(res=>{
      console.log(res)
      this.list=res.data.res
    })
  }
  }
}
</script>

<style scoped>

</style>
